<?php

use App\Enums\OpenShop\InvestmentPromotion\MainProcessEnum;
use App\Models\OpenShop\ShopEngineeringConstruction\OpenShopEngineeringConstructionModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateOpenShopEngineeringConstruction extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('open_shop_engineering_construction', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('mainProcessId')->default(0)->comment('开店主流程id');
            $table->string('orderNo', 60)->default('')->comment('开店订单号');
            $table->unsignedTinyInteger('step')->default(0)->comment(enumToMigrationComment(MainProcessEnum::MAIN_PROCESS_ENGINEER_CONSTRUCT_MAP, "营建步骤"));
            $table->unsignedInteger('engineeringConstructionStartTime')->default(0)->comment('施工进场时间');
            $table->unsignedInteger('engineeringConstructionFinishTime')->default(0)->comment('施工完成时间');

            $table->unsignedTinyInteger('finishStatus')->default(0)->comment(enumToMigrationComment(OpenShopEngineeringConstructionModel::FINISH_STATUS_MAP, "通过状态"));

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '开店 - 工程营建阶段';

            $table->unique(['orderNo'], 'idx_orderNo');
            $table->unique(['mainProcessId'], 'idx_mainProcessId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('open_shop_engineering_construction');
    }
}
